<?php

namespace App\Http\Controllers\Admin;


use Illuminate\Http\Request;
use Style, DB;

class CompanyBrowseController extends CommonController{
    /**
     * 查看简历统计
     * @return mixed
     */
    public function resumeBrowse(Request $request){
        $input = arrayFilter($request->only(['keyword', 'days']));
        $days = (!empty($input['days'])) ? date('Y-m-d H:i:s', strtotime('-' . $input['days'] . ' days'))  : '';
        //几天内
//        $date = date('Y-m-d H:i:s', strtotime('-' . $days . ' days'));
        $companyInfo = DB::table('buy_resume as t1')
            ->join('company_users as t2', 't1.company_uid', '=', 't2.uid')
            ->select(
                DB::raw('count(*) as countResume'),
                't1.com_id',
                't2.uid', 't2.username', 't2.company_name', 't2.last_login_ip', 't2.last_login_time', 't2.regtime', 't2.viptime'
            )
            ->where('t1.created_at', '>', $days)
            ->groupBy('t1.company_uid')
            ->orderBy('countResume', 'desc')
            ->paginate(20);
        //分页分配参数 过滤boolean假值
        $appends = arrayFilter($input);
        return Style::view('admin.safety.resumeBrowse', compact('companyInfo', 'appends'));
    }
}
